//
//  TransView.m
//  Bus
//
//  Created by wangjiajia on 13-12-4.
//  Copyright (c) 2013年 wangjiajia. All rights reserved.
//

#import "TransView.h"
#import "UIButton+Bootstrap.h"
@implementation TransView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        //样式都在xib中指定了，这修改没用
        self.layer.cornerRadius = 5.0;
        self.backgroundColor = UIColorFromRGBA(0xFFFFFFAA);
        self.spTextField.frame=CGRectMake(20, 20, 180, 200);
        [self.save primaryStyle];
        // Initialization code
        
        [self.save addTarget:self action:@selector(saveBtnClicked:) forControlEvents:UIControlEventTouchUpInside];
        
    }
    return self;
}

-(void)saveBtnClicked:(id)sender{
    [self dismissAlert];
    if(self.saveBlock){
        self.saveBlock();
    }
}
-(void)passBtnClicked:(id)sender{
     [self dismissAlert];
    if(self.passBlock){
        self.passBlock();
    }
}
-(void)rejectBtnClicked:(id)sender{
     [self dismissAlert];
    if(self.rejectBlock){
        self.rejectBlock();
    }
}
-(void)cancelBtnClicked:(id)sender{
     [self dismissAlert];
    if(self.cancelBlock){
        self.cancelBlock();
    }
}
- (void)show
{
    UIWindow *shareWindow = [UIApplication sharedApplication].keyWindow;
    self.center=shareWindow.center;
    [shareWindow addSubview:self];
}

- (void)dismissAlert
{

    [self removeFromSuperview];
    //[self animateRemoveFromSuperview];
    if (self.cancelBlock) {
        self.cancelBlock();
    }
}
/**
 *  加入动画
 */
- (void)animateRemoveFromSuperview
{
   [super removeFromSuperview];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end
